<!DOCTYPE html>
<html>

	<head lang="en">
		<meta charset="UTF-8">
		<title>注册</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<meta name="format-detection" content="telephone=no">
		<meta name="renderer" content="webkit">
		<meta http-equiv="Cache-Control" content="no-siteapp" />

		<link rel="stylesheet" href="../AmazeUI-2.4.2/assets/css/amazeui.min.css" />
		<link href="../css/dlstyle.css" rel="stylesheet" type="text/css">
		<script src="../AmazeUI-2.4.2/assets/js/jquery.min.js"></script>
		<script src="../AmazeUI-2.4.2/assets/js/amazeui.min.js"></script>
		<!-- 引入 Vue.js-->
		<script src="plugins/vue/dist/vue.min.js"></script>
		<!--引入axios-->
		<script src="plugins/axios/dist/axios.min.js"></script>
		<!--引入公共的js-->
		<script src="common/common.js"></script>

	</head>

	<body>

		<div class="login-boxtitle">
			<a href="home/demo.html"><img alt="" src="../images/logobig.png" /></a>
		</div>

		<div class="res-banner">
			<div class="res-main">
				<div class="login-banner-bg"><span></span><img src="../images/big.jpg" /></div>
				<div class="login-box">

						<div class="am-tabs" >
							<ul class="am-tabs-nav am-nav am-nav-tabs am-nav-justify">
								<li><a href="">绑定手机号</a></li>
							</ul>

							<div class="am-tabs-bd">
								<!-- 手机号注册-->
								<div class="" id="app">
									<form method="post">
                 <div class="user-phone">
								    <label for="phone"><i class="am-icon-mobile-phone am-icon-md"></i></label>
								    <input type="tel" v-model="formData.phone" placeholder="请输入手机号">
                 </div>																			
										<div class="verification">
											<label ><i class="am-icon-code-fork"></i></label>
											<input type="tel" v-model="formData.code" placeholder="请输入验证码">
											<button class="btn" type="button"   :disabled="disabled" @click="sendMobileCode()">
												<span id="dyMobileButton" v-text="btnText"></span>
											</button>
										</div>
									</form>
								 <div class="login-links">
										<label for="reader-me">
											<input id="reader-me" type="checkbox"> 点击表示您同意商城《服务协议》
										</label>
							  	</div>
										<div class="am-cf">
											<button type="button"  class="am-btn am-btn-primary am-btn-sm am-fl" @click="binder">绑定</button>
										</div>
								
									<hr>
								</div>

								<script>
									$(function() {
									    $('#doc-my-tabs').tabs();
									  })
								</script>

							</div>
						</div>

				</div>
			</div>
			
					<div class="footer ">
						<div class="footer-hd ">
							<p>
								<a href="# ">恒望科技</a>
								<b>|</b>
								<a href="# ">商城首页</a>
								<b>|</b>
								<a href="# ">支付宝</a>
								<b>|</b>
								<a href="# ">物流</a>
							</p>
						</div>
						<div class="footer-bd ">
							<p>
								<a href="# ">关于恒望</a>
								<a href="# ">合作伙伴</a>
								<a href="# ">联系我们</a>
								<a href="# ">网站地图</a>
								<em>© 2015-2025 Hengwang.com 版权所有. 更多模板 <a href="http://www.cssmoban.com/" target="_blank" title="模板之家">模板之家</a> - Collect from <a href="http://www.cssmoban.com/" title="网页模板" target="_blank">网页模板</a></em>
							</p>
						</div>
					</div>
	</body>

<script>
	new Vue({
		el:"#app",
		data:{
			formData:{
			    phone:'',
				code:''
			},
            btnText:"获取",
            disabled:false
		},
		methods:{

		    //注册的按钮方法
            binder(){
				let parem = getRequestUrl();
                let par={
                    phone:this.formData.phone,
                    code:this.formData.code,
					token:parem.access_token,
					openid:parem.openid

				}
				this.$http.post("/wxUser/binder",par).then(res=>{
                    ///http://localhost:8080/user/login
                    let {success,message,resultObj}=res.data;
                    if (success){//resultObj  Map
                        localStorage.setItem("TOKEN",resultObj.token);
                        //JSON.stringify(resultObj.user)  把 js对象转换JSON字符串
                        localStorage.setItem("USER",JSON.stringify(resultObj.user));

                        //登录成功 跳转到首页
                        location.href="/index.html";
                    }else {
                        alert(message);
                    }

				})
			},
            sendMobileCode(){
                //手机号的合法性验证
              if(!this.formData.phone){
				  alert("请输入合法的手机号");
				  return;
			  }
			  //准备发送到后台的数据
				let param={
                  phone:this.formData.phone,//发送的手机号
				  codeType:"BINDER"//验证码类型
				}

			  //把按钮设置为不能点击
              this.$http.post("/code/sendCode",param).then(res=>{
                 let {success,message}=res.data;
                 if (success){
                     this.disabled=true;
                     //添加一个定时器 执行的时间间隔为1s
                     var time=5;
                     //把获取 更改为 60s倒计时
                     this.btnText=time+"s";
                     let that =this;
                     var interval =window.setInterval(function () {
                         time--;
                         if (time==0){
                             that.btnText="重发";
                             //移出定时任务
                             window.clearInterval(interval)
                             that.disabled=false;
                             return;
                         }
                         //console.debug(time)
                         that.btnText=time+"s";
                     },1000);
				 }else {
					alert(message);
				 }

			  })


			}
		},
		mounted(){

		}


	})


</script>
</html>